package com.example.oss.controller;

import com.example.model.response.Result;
import com.example.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/oss")
public class OssController {

    @Autowired
    private OssService ossService;

    @PostMapping("/upload")
    public Result upload(@RequestBody MultipartFile file){

        return Result.success(ossService.uploadFile(file));
    }

    @GetMapping("/get")
    public Result getUrl(@RequestParam("name") String objectName) {
        return Result.success(ossService.getPublicUrl(objectName));
    }


}
